import 'package:mvvm_provider/base/base_state.dart';
import 'package:mvvm_provider/page/mine/data/model/info_model.dart';
import 'package:mvvm_provider/page/mine/data/repository/mine_repository.dart';
import 'package:mvvm_provider/page/mine/states/mine_detail_type2_state.dart';
import '../../../base/base_view_model.dart';
import '../../../config/handle_state.dart';
import '../../../model/response_model.dart';
import '../../../widgets/easy_loading.dart';

class MineDetailType2ViewModel extends BaseViewModel<MineDetailType2State> {
  MineDetailType2ViewModel() : super(MineDetailType2State());

  /// 获取详情数据
  Future<void> geDetailData(int entityId) async {
    XsEasyLoading.showLoading();
    ResponseModel responseModel = await MineRepository.getDetailInfoData<InfoListModel>(entityId);
    XsEasyLoading.dismiss();
    state.netState = HandleState.handle(responseModel);
    if (state.netState == NetState.dataSuccessState) {
      state.model = responseModel.data;
    }
    notifyListeners();
  }
}
